# -*- coding: utf-8 -*-
# ====================================================
#
#   Author        : 诺言Nuoyan
#   Email         : 1279735247@qq.com
#   Gitee         : https://gitee.com/charming-lee
#   Last Modified : 2024-07-10
#
# ====================================================


import mod.client.extraClientApi as clientApi
from mod.common.minecraftEnum import *
import nuoyanlib_client as nyl
from nuoyanlib_client import event, notify_server
from ..constants import *


ClientSystem = clientApi.GetClientSystemCls()


class HackerButtons(nyl.NuoyanScreenNode):
    def __init__(self, namespace, name, param):
        super(HackerButtons, self).__init__(namespace, name, param)
        self.visible = True
        self.openBtn = None
        self.powerBtn = None
        self.speedBtn = None
        self.kxtsBtn = None
        self.jumpBtn = None

    # =========================================== Engine Event Callback ================================================

    def Create(self):
        super(HackerButtons, self).Create()
        self.openBtn = self.GetBaseUIControl(UI_PATH_OPEN_BTN).asButton()
        self.openBtn.AddTouchEventParams()
        self.openBtn.SetButtonTouchUpCallback(self.OnOpenBtnTouchUp)
        self.powerBtn = self.GetBaseUIControl(UI_PATH_POWER_BTN).asButton()
        self.powerBtn.AddTouchEventParams()
        self.powerBtn.SetButtonTouchUpCallback(self.OnPowerBtnTouchUp)
        self.speedBtn = self.GetBaseUIControl(UI_PATH_SPEED_BTN).asButton()
        self.speedBtn.AddTouchEventParams()
        self.speedBtn.SetButtonTouchUpCallback(self.OnSpeedBtnTouchUp)
        self.kxtsBtn = self.GetBaseUIControl(UI_PATH_KXTS_BTN).asButton()
        self.kxtsBtn.AddTouchEventParams()
        self.kxtsBtn.SetButtonTouchUpCallback(self.OnKxtsBtnTouchUp)
        self.jumpBtn = self.GetBaseUIControl(UI_PATH_JUMP_BTN).asButton()
        self.jumpBtn.AddTouchEventParams()
        self.jumpBtn.SetButtonTouchUpCallback(self.OnJumpBtnTouchUp)
        self.hideHackerBtns()

    # =========================================== Custom Event Callback ================================================

    @event(namespace=MOD_NAME, system_name=HACKER_SERVER_NAME)
    def RequestOpenHackerUI(self, args):
        """
        开启科学家UI。
        """
        self.showHackerBtns()

    @event(namespace=MOD_NAME, system_name=HACKER_SERVER_NAME)
    def RequestCloseHackerUI(self, args):
        """
        关闭科学家UI。
        """
        self.hideHackerBtns()

    # ================================================ UI Callback =====================================================

    @notify_server
    def OnOpenBtnTouchUp(self, args):
        """
        开关按钮。
        """

    @notify_server
    def OnPowerBtnTouchUp(self, args):
        """
        力量按钮。
        """

    @notify_server
    def OnSpeedBtnTouchUp(self, args):
        """
        加速按钮。
        """

    @notify_server
    def OnKxtsBtnTouchUp(self, args):
        """
        抗性提升按钮。
        """

    @notify_server
    def OnJumpBtnTouchUp(self, args):
        """
        高跳按钮。
        """

    # ============================================== Basic Function ====================================================

    def show(self):
        self.visible = True
        self.SetScreenVisible(True)

    def hide(self):
        self.visible = False
        self.SetScreenVisible(False)

    def showHackerBtns(self):
        self.powerBtn.SetVisible(True)
        self.speedBtn.SetVisible(True)
        self.kxtsBtn.SetVisible(True)
        self.jumpBtn.SetVisible(True)
        self.openBtn.GetChildByName("button_label").asLabel().SetText("关闭科学家")

    def hideHackerBtns(self):
        self.powerBtn.SetVisible(False)
        self.speedBtn.SetVisible(False)
        self.kxtsBtn.SetVisible(False)
        self.jumpBtn.SetVisible(False)
        self.openBtn.GetChildByName("button_label").asLabel().SetText("开启科学家")

















